﻿using Microsoft.SharePoint;
using SharePoint.Orm.Helpers;

namespace SharePoint.Orm.Metal.Model {
	public class ContentTypeFieldInfo {
		protected readonly SPField _field;
		protected readonly string _name;
		protected readonly CodeGeneratorConfiguration _config;
		protected readonly SiteInfo _siteInfo;

		public ContentTypeFieldInfo(CodeGeneratorConfiguration config, SiteInfo siteInfo, SPField field) {
			_config = config;
			_siteInfo = siteInfo;
			_field = field;
			_name = config.NameRewriter.ToFieldName(field);
		}

		public string Name {
			get { return _name; }
		}

		public string Id {
			get { return _field.Id.ToString(); }
		}

		public string Title {
			get { return _field.Title; }
		}

		public string StaticName {
			get { return _field.StaticName; }
		}

		public string Type {
			get { return TypeSystem.TypeToCodeString(_config.FieldTypeResolver.GetFieldType(_siteInfo, _field)); }
		}
	}
}
